<template>
  <div>
    <div class="content-box mb-7">
      <img src="/about_3.png" alt="" class="bg-img" />
      <div class="content d-flex">
        <div class="d-none d-sm-flex content-left align-self-end mb-7">
          <span
            class="white--text"
            :style="`font-size: ${this.$i18n.locale == 'zh' ? 23 : 18}px`"
            >{{ $t('descOne')
            }}<span class="black--text">{{ $t('descTwo') }}</span
            >{{ $t('descThree') }}</span
          >
        </div>
        <div class="content-right bg-white mr-md-10 px-md-8 overflow-y-auto">
          <img src="/index_2.png" alt="" class="d-none d-sm-flex" />
          <p
            v-for="(item, index) in $t('aboutPage.middleContent')"
            :key="index"
          >
            {{ item }}
          </p>
        </div>
      </div>
    </div>
    <p class="title-text">{{ $t('newsTitle') }}</p>
    <v-row class="list mb-5">
      <v-col v-for="item in newsList" :key="item.id" cols="12" sm="12" md="4">
        <nuxt-link
          class="d-flex item"
          :to="{ name: 'newsDetail', params: { id: item.id } }"
        >
          <img :src="item.img" alt="" />
          <div class="item-content">
            <p>{{ item.name }}</p>
            <span class="desc">{{ item.miaoshu }}</span>
            <p>{{ item.create_time }}</p>
          </div>
        </nuxt-link>
      </v-col>
    </v-row>
    <div class="text-center">
      <nuxt-link to="/news" class="see-more-btn">{{ $t('more') }}</nuxt-link>
    </div>
  </div>
</template>

<script>
export default {
  async asyncData({ store, $axios }) {
    const data = await $axios.$post('news/index', {
      language: store.state.locale,
      page: 1,
      rows: 6,
    })
    return {
      newsList: JSON.parse(data).data.data,
    }
  },
  watch: {
    '$store.state.locale'() {
      this.getData()
    },
  },
  methods: {
    async getData() {
      const data = await this.$axios.$post('news/index', {
        language: localStorage.getItem('lang'),
        page: 1,
        rows: 6,
      })
      this.newsList = JSON.parse(data).data.data
    },
  },
}
</script>

<style lang="scss" scoped>
.content-box {
  position: relative;
  .bg-img {
    width: 100%;
  }
  .content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    .content-left {
      flex: 1;
      background: rgba($color: #eee, $alpha: 0.5);
      font-size: 23px;
      padding: 10px 0 10px 24px;
    }
    
    .bg-white {
      background: rgba(255, 255, 255, 0.8);
    }
    .content-right {
      max-width: 570px;
      position: relative;
      color: #333;
      justify-content: center;
      flex-direction: column;

      img {
        position: absolute;
        width: 450px;
        height: 115px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }
      p {
        font-size: 15px;
        margin-bottom: 10px;
      }
    }
  }
}
.title-text {
  position: relative;
  text-align: center;
  color: $blue198;
  font-size: 19px;

  &::after {
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 13px;
    height: 2px;
    background: $blue198;
  }
}

.list {
  img {
    width: 100px;
    height: 80px;
    margin-right: 12px;
  }
  .item-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    overflow: hidden;
    p {
      margin-bottom: auto;
      &:first-child {
        width: 100%;
        color: #333;
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      &:last-child {
        color: #999;
        font-size: 12px;
        margin-bottom: 0;
        align-self: flex-end;
      }
    }
    span {
      width: 100%;
      color: #666;
      font-size: 13px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }
  }
}

.see-more-btn {
  color: $blue198;
  padding: 7px 28px;
  border-radius: 100px;
  border: 1px solid $blue198;
  font-size: 11px;
}

@media screen and (max-width: 765px) {
  .content {
    position: relative !important;
  }
}
</style>
